var app = getApp();
const requireHttps = app.globalData.requireHttps //获取require域名
const WXBizDataCrypt = require('../../utils/RdWXBizDataCrypt.js');
Page({
  data: {
    nearGarage: [],
    is_show: 'hide',
    showParking: true
  },
  onLoad: function() {
    let _this = this;
    _this.getNearGarage()
  },
  onShow: function() {
  },
  //查看
  seeCar: function(e) {
    // console.log(e)
    app.globalData.gid = e.currentTarget.dataset.gid
    app.globalData.g_address = e.currentTarget.dataset.g_address
    app.globalData.g_name = e.currentTarget.dataset.g_name
    app.globalData.juli = e.currentTarget.dataset.juli
    app.globalData.g_usable = e.currentTarget.dataset.usable
    setTimeout(function() {
      wx.navigateTo({
        url: '/pages/setParking/setParking',
      })
    }, 150)
  },
  //获取附近车库
  getNearGarage: function() {
    wx.showLoading({
      title: '加载中',
      mask: true
    })
    let _this = this;
    //发起网络请求获取用户附近的车库
    wx.request({
      url: '' + requireHttps + '/api/garage/getNearGarage',
      data: {
        lat: app.globalData.latitude,
        lng: app.globalData.longitude
      },
      method: 'post',
      success: res => {
        // console.log(res)
        if (res.data.data == '') {
          _this.setData({
            showParking: false,
            noParking: '该地区暂无车库',
          })
        }
        _this.setData({
          nearGarage: res.data.data
        })
        setTimeout(() => {
          wx.hideLoading()
        })
      }
    })
  },
})